home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Topik
/
Topik - Disk 39 - Educational (19xx)(Topik Public Domain)(PD)[WB].zip
/
Topik - Disk 39 - Educational (19xx)(Topik Public Domain)(PD)[WB].adf
/
plotxy
/
PlotXY.doc
< prev
next >
Wrap
Text File
|
1991-03-11
|
22KB
|
552 lines
PlotXY Version 1.1
By
Robert Mack
Copyright, 1989
1 Introduction
------------
PlotXY is a 2-D plotting package that plots X and Y data points
from a file on several types of graphs. PlotXY was written completely
in C using the Manx Aztec V3.6a C compiler. PlotXY was compiled using
the +fi option for the IEEE Double Precision Floating Point Emulation
and linked using the mal32.lib for access to the Amiga's library.
There are several good plotting programs in the public domain,
but the majority of them accept only a mathematical function as
input (as far as I know). I wanted a plotting package that
accepted X and Y data points as input. I also wanted it to be very
flexible as far as the output was concerned. PlotXY allows the user
to define just about every aspect of the plot that I could think of.
The user can determine the type of graph (i.e. linear, linear-log,
log-linear, log-log, and histogram), the size of the graph (by input
or interactively), the color of the graph and data, the marker type,
the line type (although there are only 6 pre-defined types), annotation
and title, and the graph characteristics (i.e. X /Y bounds, major/minor
tick marks, grid, and overlay option). Also included are linear
regression analysis and polynomial fit analysis. All these options
are explained in detail section 3.
PlotXY is in the public domain. The author grants permission
to duplicate this software provided that no commercial gain can be
had as a consequence of use or reproduction of this software and
that this and other identifying information be left intact. The author
may not be held liable for the consequences of use or misuse of this
software.
1.1 What's new in Version 1.1
--------------------------
The new features for PlotXY Version 1.1 are denoted by a " * "
next to the item. The following is a brief description of the
new features and some bug fixes:
1) The integer gadgets had a format bug that caused the system
to sometimes hang. This is now fixed. Thanks to EKIM (Plink ID).
2) I changed the the number type from float to exponent for
the regression output as suggested by OES895 (Plink ID).
3) The filter (smooth) function had a slight bug. It refused
to smooth the first 3 numbers. This is now fixed.
4) The linetype would not get set back to the correct
type after linear or polynomial regression functions
were executed. This bug is fixed.
5) I redesigned the color and line type gadgets. (I was
experimenting with PowerWindows 2.0).
6) I made the string gadget that requested text look a
little better.
7) I added Steve Tibbett's Simple Requesters because I thought
they were better looking than the systems, easy to
implement, and more flexible. (The OKAY gadgets can be
turned off by typing any key).
8) I improved the histogram. I also added two more types.
Besides the standard, there is now the probability and
cumulative histogram. See section 3.2 for more details.
9) Added statistics to the analysis menu. See section 3.3.
10) Added the capability to contour an X, Y, Z field (were Z is
is some parameter at a location X and Y of a grid). See
section 3.2.6.
11) I made an Icon for PlotXY.
12) Last and maybe least, I removed my name from the title
bar and put in under the menu item "About" in the
Project menu. The version number can also be found here.
2. How to get started using PlotXY (see section 3.2 for contour plots)
-------------------------------
I've provided several example input files so that you may
experiment with PlotXY. The files are:
lotto.dat Frequency of the Maryland Lotto numbers
picked from the beginning to 01/14/89.
sine.dat The sine of 0 to 360 degrees.
tempf.dat The temperatures (degrees Fahrenheit) at Baltimore
for 72 hours (I don't remember the dates...sometime
in the fall).
The following is an example of typical steps that are used
to plot a X/Y graph with PlotXY.
1) PLOTXY expects there to be a logical device "GDATA:", which
corresponds to the directory where the data for plotting is
located. This can be accomplished using the CLI "ASSIGN"
command (i.e., ASSIGN GDATA: DF1:Graphdata).
2) Open and read the data file. Choose the menu item "Open"
in the project menu. A file requester is presented for
selection.
3) Choose the graph type under the "Graph Type" menu.
4) Next choose the graph options that you want under the Utilities
menu. The default is a point plot. You may also choose to
plot a line connecting the data points. The point, line, grid,
and overlay options can all be activated at the same time.
They are not mutually exclusive. If they are activated, a
check mark will appear be for an item. To turn them off, you
must reselect the item. The check mark will no longer be
displayed.
5) Choose the graph and background colors from the "Color" menu.
6) Plot the graph using the Draw item under the "Project" menu.
3. Description of Menu Items
-------------------------
3.1 Project Menu
3.1.1 Draw
This menu item initiates the plotting of the graph. After
the user acknowledges that he/she wants to begin, a setup
window appears. This window allows the user to set up
different plot characteristics (see Setup description below
for details). If a contour map is going to be drawn the
user is prompted for a file name after the Draw item is
selected (see section 3.2.6 for more details).
3.1.1.1 Setup
Setup opens a window with gadgets that allow the user
to change the graph characteristics. The following is
a list of graph characteristics that can be changed:
1) Graph Bounds (float)
-----------------------
XMAX - X maximum
XMIN - X minimum
YMAX - Y maximum
YMIN - Y minimum
Initially the graph bounds default to the X and Y data bounds
(X and Y minimum and maximum). Log plots default to
XMAX and YMAX = 1000.0 and XMIN and YMIN = 1.0.
2) Tick marks (integer)
-----------------------
XMAJ - major tick marks along the X axis. Default is 5.
YMAJ - major tick marks along the Y axis. Default is 5.
XMINOR - minor tick marks along the X axis. Default is 5.
YMINOR - minor tick marks along the Y axis. Default is 5.
3) Box size (float)
-------------------
XUL - The pixel upper left hand corner of the graph.
YUL - The line upper left hand corner of the graph.
Width - The graph width.
Height - The graph height.
4) Features
-----------
Marker type - The marker type specifies what character is
drawn to mark the data point. The default is
"+". WARNING: The character font I use is
the Siesta font (Microsmiths). I adjusted the
X and Y coordinates for the TEXT command to make
the characters draw so that the data point is
at the middle of the character. I checked the
default Topaz font and it looks okay, but other
fonts may not be centered. If this is a problem,
let me know. I use the Siesta font because it
looks the best (IMHO).
Data color - Change the color for the data. Default is green.
See color menu for default colors.
Precision - Precision is the number of decimal places that
are plotted to the right of the decimal point
(i.e. 0 plots integer). The default is 1.
Line pattern - Change the line pattern. The line option must
be active. The default is a solid line.
3.1.2 Open
Open a text file containing n points to plot (max 1000). The
file must have the following format:
record 1 Number of points (integer)
record 2 X1 Y1
record 3 X2 Y2
. . .
. . .
record i Xn Yn
X and Y can be either floating point or integer. If you plan
on doing a line plot make sure the points are sorted. PlotXY
does NOT sort the points. A file requester will be presented
for file selection.
3.1.3 New
Erase the screen (plot) for a new plot. The file opened
previously is still active.
3.1.4 SaveIFF
Save the screen (plot) as an IFF file. A file requester
will appear for the user to enter the IFF file name.
3.1.5 Print
Print the screen (plot) to a dot matrix line printer. There
is an option to set the background color to white for
printing on a black and white dot matrix printer. (I've
never tried it on a color printer).
3.1.6 Credits
This item displays a window that gives credit for the
public domain routines that were used. Thank you.
3.1.7 About *
My name and the PlotXY version number.
3.1.8 Quit
Quit PlotXY.
3.2 Graph Type Menu
3.2.1 Linear
Indicates a linear graph is desired (default).
3.2.2 Linear-Log
Indicates a linear (X) - log (Y) graph is desired.
3.2.3 Log-Linear
Indicates a log (X) - linear (Y) graph is desired.
3.2.4 Log-Log
Indicates a log graph is desired.
3.2.5 Histogram *
3.2.5.1 Standard Histogram
Indicates a standard histogram graph is desired
(X versus Y value). The abscissa represents values
of the variate and the ordinate represents the
class frequencies. The histogram consists of
adjacent rectangular boxes whose bases extend between
successive mathematical limits and whose heights are
equal to the frequency within each class. The rectangular
boxes are plotted with the center at the mid-points
of the class intervals.
3.2.5.2 Probability Histogram
Indicates a probability histogram graph is desired
(X versus Y value expressed as a percentage of the total).
This histogram is analogous to the standard histogram,
except that the height of the boxes is not the class
frequency but the class frequency divided by N, the
total observations.
3.2.5.3 Cumulative Frequency Histogram (Ogive)
Indicates a cumulative frequency histogram graph is
desired (X versus the cumulative sum of the Y values
expressed as a percentage of the total). Values range
from 0 to 100 percent. It is useful in determining the
distribution of an element in terms of "more than" or
"less than" a certain value (e.g., the median is the
value of X at 50%). The abscissa shows the successive
upper mathematical limits (just as does the abscissa
of a standard histogram) and the ordinate shows the
percentage frequency less than each mathematical
limit. For each upper limit, there exists one
cumulative frequency percentage. These points are
plotted and connected by a straight line (set the
"Line" option in order to connect the points). Thus,
the ogive always starts at the point of zero frequency
on the graph and ends at the point of 100%, or total
frequency.
3.2.5.4 How Histogram Works
Follow the first 6 steps in section 2 for drawing
a regular plot. The following are additional steps:
7) A window will open listing the histogram parameters
that can be changed. The first parameters have to do
with the class intervals. The lower limit of the first
and last class interval can be adjusted. The class
interval is determined by the range of X values
and the class interval size (see bin size described
below). The defaults have been initially set to the
minimum and maximum values of X. The bin size should
be chosen to given equal class intervals (bins). Unequal
intervals are not supported. The lower limits of the
first and last lower limits for the class interval
should be set based on the equal class intervals.
The second parameter that can be changed is the bin
size (class interval size). The default is set to 1.
I chose these defaults for a discrete case. That
is, there is only frequency data for each X value and
not for a range of X values. (See the lotto.dat case
provided).
8) Select the "OK" gadget to continue or the "NO"
gadget to cancel the histogram plot.
9) Next the familiar "Setup" window will be displayed.
Adjust the plot characteristics accordingly. The
histogram will then be plotted.
3.2.6 Contour*
Indicates a contour plot is desired.
3.2.6.1 How Contour Works
I've provided one example grid input file so that you may
experiment with the contour option in PlotXY. The file is
"pres.grd". I generated this atmospheric surface pressure
(millibars) grid field using weather service observations from
the central United States. From the observations I performed
an objective analysis using M.I.P.S (Meteorological Information
Processing System) that I wrote for use on my Amiga. (I'm a
meteorologist by profession.)
The following is an example of typical steps that are used
to generate a contour map.
1) PLOTXY expects there to be a logical device "GDATA:", which
corresponds to the directory where the data for contouring is
located. This can be accomplished using the CLI "ASSIGN"
command (i.e., ASSIGN GDATA: DF1:Graphdata).
2) Choose the graph type "Contour" under the "Graph Type" menu.
3) Open and read the data file. Choose the menu item "Draw"
in the project menu. A file requester is presented for
selection. (Note: This is different from the procedure
to plot a normal X/Y graph where the "Open" item was used.)
Choose the grid file (i.e., pres.grd).
5) Next, a window will appear showing options for contour
plotting. The window shows the number of contour levels
(maximum is 10). This number can be changed. The window
also shows the values for each contour level. The first
is the minimum data value and the last is the maximum.
The other eight values are are at equal intervals between
the min and max. These can also be changed. Finally, select
the color and line type for each contour interval. Select
the "Okay" gadget to draw the plot or "Cancel" to exit.
3.2.6.2 Grid File Format
Record 1 nx ny
Record 2 X1Y1 X1Y2 ... X1Yny
Record 3 X2Y1 X2Y2 ... X2Yny
. . . . .
. . . . .
. . . . .
Record nx+1 XnxY1 XnxY2 ... XnxYny
where nx and ny are the number of x and y grid points
(integer) and XiYi are the grid locations of parameter
Z (float).
3.3 Analysis Menu
3.3.1 Linear Regression
Linear regression allows you to analyze one
variable's relationship to another. The method
is to perform a least-squares linear regression
which is designed to minimize the sum of the
squares of the deviations of the actual data
points from the straight line of best fit. In
practice, a plot of the data points is made
and then a line is constructed (by selecting
the Linear Regression Item) that uniformly
divides the points. The data color and line
type is chosen at this point. The line is
described by y = mx + b, where m is the slope
of the line and b is the intercept. The
correlation coefficient, which is a measurement
of how well the line fitted to the data actually
does approximate the data, is also calculated.
These parameters are displayed in a separate
window.
3.3.2 Polynomial Fit
Polynomial fit uses a higher order polynomial
for a reasonably good representation of a series
of n data points (X,Y). The regression coefficients
are also estimated. The technique employs a
least-squares fit of the data by a polynomial of
order m, where m = 1,2,...10 (maximum of 10) and
examines the standard deviation s about the regression
line. The linear regression of Y upon a single
variable X can be extended to the multiple regression:
Y = a + b1X1 + b2x2 + ... + biXi + ... + bkXk,
where X1,X2,...,Xk are k different variables. If, as
frequently occurs, X1 = X, X2 = X**2, X3 = X**3, etc.,
we have a special case of multiple regression known as
polynomial or curvilinear regression.
After the data points have been plotted, select
the Polynomial Fit item under the Analysis menu.
The user is then prompted, via a integer string gadget,
to enter the order of the polynomial that will be used.
Next, the color and line type are selected. A curve
is then plotted on the graph. A separate window is
presented that displays: 1) the polynomial order,
2)the standard deviation, 3) the coefficient a, and
4) each bk regression coefficient.
3.3.3 Statistics *
The following statistics are calculated and displayed
in a separate window:
mean
mean deviation
standard deviation
variance
3.4 Utilities Menu
3.4.1 Point
Plot a character marker for the data point (default).
3.4.2 Line
Plot a line connecting the data points.
3.4.3 Grid
Plot a dashed grid at the major tick marks on the
background.
3.4.4 Overlay
This option is used to overlay data from a different
file onto the previous graph. If this item is picked,
the previous options remain. All that is plotted are
the new data points.
3.4.5 Box Mode
Enables the user to shape and move the graph box
interactively via the mouse. Menu options control
whether the box is being sized (shaped) or moved.
Use the left mouse button to define the box. Initially
this option is set to shape the box. Exit when you
are satisfied with the size and location.
3.4.6 Filter
This option does a running mean on the Y data to
perform a smoothing. Enter the number of Y data points
to use in the running mean. The data points must be sorted.
3.4.7 Annotate
This option allows the user to write text for the plot.
A string gadget is presented for input of a character
string of up to a maximum of 132 characters. Move the
text with the mouse to the location desired. Define
the location by pressing the left mouse button.
3.4.8 Title
This option lets the user write a title in the window's
title bar. The string may be up to a maximum of 132
characters.
3.5 Colors
Default colors: black, blue, green, cyan, red, magenta,
yellow, and white.
3.5.1 Background
Set the background color by selecting the appropriate
box (default: black).
3.5.2 Foreground
Set the graph color by selecting the box (default: blue).
3.5.3 Palette
Make your own palette by using C. Heath's public domain
palette tool.
4.0 Remarks
-------
PlotXY is my first program that I have released as public domain.
I've learned how to program in C on my Amiga writing PlotXY and other
programs. Therefore, I am very interested in any comments, suggestions,
and complaints that you may have. Please let me here from you. I can
be reached on BIX as RMACK or PLINK as OTR763. You can also write
me:
Bob Mack
13909 Briarwood Drive Apt. 312
Laurel, Maryland 20708